package com.five.years.common.utils;

import java.util.Random;

/**
 * @ClassName RandomUtilTest
 * @Description: TODO
 * @Author 123
 * @Date 2020/2/27
 * @Version V1.0
 **/
public class RandomUtilTest {
    public static final String allChar = "3456789abcdefghjkmnpqrstuvwxy";
    /**
     * 返回一个定长的随机字符串(只包含大小写字母、数字)
     *
     * @param length
     *            随机字符串长度
     * @return 随机字符串
     */
    public static String generateString(int length) {
        StringBuffer sb = new StringBuffer();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            sb.append(allChar.charAt(random.nextInt(allChar.length())));
        }
        return sb.toString();
    }
}
